package assignment2;

/*import javax.jms.*;
import javax.naming.Context; 
import javax.naming.InitialContext; 
import java.util.Scanner;

public class Producer {

	public static void main(String[] args) {
		Producer p = new Producer();
		Scanner in = new Scanner(System.in);
		
		String c;
		do {
			System.out.println("Enter message:");
			c = in.nextLine();
			System.out.println("Sending: " + c);
			if (c != "") p.raise(c);			
		} while (c != "");	
	}
	
	public void raise(String m)	{
		try {
			Context ctx = new InitialContext();
			
			// Lookup the TopicConnectionFactory
			TopicConnectionFactory tfc = (TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");
			
			// Lookup the Topic
			Topic t = (Topic) ctx.lookup("Messages");
			
			// Create a new Topic Connection
			TopicConnection tc = tfc.createTopicConnection();
			
			// Start a new Topic Session
			TopicSession ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
			
			// Create the publisher
			TopicPublisher tp = ts.createPublisher(t);
			
			// Create a message
			TextMessage tm = ts.createTextMessage();
			
			// We're not sending messages on behalf of 'Alice'
			tm.setStringProperty("sender", "Alice");
			
			// Set the text of the message
			tm.setText(m);
			
			// Send the message
			tp.send(tm);
			
			// Close the topic connection
			tc.close();
		} catch (Exception e) {		
			System.out.println("Exception:" + e.getMessage());
			e.printStackTrace();			
		}		
	}	

}*/
